﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using Gao.Poker.DataPrivader;
using Gao.Poker.Domain;

namespace Gao.Poker.App
{
    public class PokerInitializer : DropCreateDatabaseIfModelChanges<PokerDbContext>
    {
        protected override void Seed(PokerDbContext context)
        {
            context.User.Add(new User() {UserName = "admin", Password = "admin"});
            context.SaveChanges();

            var member = new Member();
            member.Address = "苏州市新区万枫家园65栋";
            member.Birthday = new DateTime(1984,07,11);
            member.CardNo = "8888888";
            member.ConsumeMoney = 1233434;
            member.Email = "Warrior.gao@gmail.com";
            member.IdNo = "620503198407111213";
            member.Points = 12343232;
            member.Name = "高士秦";
            member.OpenCardDate = DateTime.Now;
            member.Remark = "备注";
            member.Telephone = "13862176487";

            context.Members.Add(member);

            member = new Member();
            member.Address = "苏州市新区万枫家园65栋";
            member.Birthday = new DateTime(1984, 07, 11);
            member.CardNo = "8888889";
            member.ConsumeMoney = 1233434;
            member.Email = "Warrior.gao@gmail.com";
            member.IdNo = "620503198407111213";
            member.Points = 12343232;
            member.Name = "一一";
            member.OpenCardDate = DateTime.Now;
            member.Remark = "备注";
            member.Telephone = "13862176487";

            context.Members.Add(member);

            member = new Member();
            member.Address = "苏州市新区万枫家园65栋";
            member.Birthday = new DateTime(1984, 07, 11);
            member.CardNo = "8888887";
            member.ConsumeMoney = 1233434;
            member.Email = "Warrior.gao@gmail.com";
            member.IdNo = "620503198407111213";
            member.Points = 12343232;
            member.Name = "网速";
            member.OpenCardDate = DateTime.Now;
            member.Remark = "备注";
            member.Telephone = "13862176487";

            context.Members.Add(member);
            context.SaveChanges();

            var table = new Tables {Number = "1", Seating = 10, Remark = "xxxx"};
            context.Tableses.Add(table);

            table = new Tables {Number = "2", Seating = 10, Remark = "xxxx"};
            context.Tableses.Add(table);

            table = new Tables {Number = "3", Seating = 10, Remark = "xxxx"};
            context.Tableses.Add(table);

            table = new Tables { Number = "4", Seating = 10, Remark = "xxxx" };
            context.Tableses.Add(table);
            table = new Tables { Number = "5", Seating = 10, Remark = "xxxx" };
            context.Tableses.Add(table);
            table = new Tables { Number = "6", Seating = 10, Remark = "xxxx" };
            context.Tableses.Add(table);
            table = new Tables { Number = "7", Seating = 10, Remark = "xxxx" };
            context.Tableses.Add(table);
            table = new Tables { Number = "8", Seating = 10, Remark = "xxxx" };
            context.Tableses.Add(table);
            context.SaveChanges();

            var competition = new Competition {Name = "比赛测试", TablesNum = "1,2", Date = new DateTime()};
            context.Competitions.Add(competition);
            context.SaveChanges();
        }
    }
}
